package com.star.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.Set;

/**
 * URL规则
 *
 * @author 孙星阳
 * @date 2017/9/27 下午3:48
 */
@Table(name = "conf_url_rule")
@Entity
@Getter
@Setter
@ToString
@AllArgsConstructor
public class UrlParseRule extends AbstractEntity {

    public UrlParseRule() {
        method = "GET";
    }

    public UrlParseRule(String rule) {
        this();
        this.rule = rule;
    }

    private static final long serialVersionUID = 1L;

    @Column(columnDefinition = "varchar(38) not null", nullable = false)
    private String regionId;

    @Column(nullable = false)
    private String rule;

    @Column(nullable = false)
    private String method;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "urlRuleId", insertable = false, updatable = false)
    private Set<UrlRuleParam> urlRuleParams;

}